$(function (){

    $(".voice").bind("change",function () {
        //获取span标签的对象
        $("#spd").html($(".spd").val());
        $("#pit").html($(".pit").val());
        $("#vol").html($(".vol").val());

    })

    $(".btn").bind("click",function () {

        var text = $(".text").val();
        var spd = $(".spd").val();
        var pit = $(".pit").val();
        var vol = $(".vol").val();
        var per = $(".choose option:selected").val();
        if (text == "") {
            confirm("文本框不能为空!!!")
            return;
        }
        $.ajax({
            type: "post",
            url: "/speech?action=voiceSpeech",
            data: {
                text: text,
                spd: spd,
                pit: pit,
                vol: vol,
                per: per
            },
             dataType: "json",
            success: function (data){
                var audio = $("#audio")[0]
                    audio.setAttribute("src","data:audio/mp3;base64,"+data.data)
                    audio.load()
                    audio.play()
                console.log("成功")
                console.log(data)
            },
            error: function (data){
                console.log("失败")
            }
        })

    })
})



